﻿@using Classified.Service
@using MvcPaging
@model IPagedList<Classified.Domain.Entities.ClassifiedAd>
@{
    ViewBag.Title = "Search By:" + ViewBag.CategoryName;
    Layout = "~/Views/Shared/_Layout.cshtml";
 
}
<div class="row" id="dvSearchList">
    <div class="span12">
        <div class="alert-info">
            <h2>
                Result for :<small> @ViewBag.CategoryName</small>
            </h2>
        </div>
        <table class="table">
            @foreach (var item in Model.Where(x => x.IsEnhanced))
            {
                <tr>
                    <td class="table-img">
                        <div class="list-item-pic thumbnail">
                            @if (item.ClassifiedPicture.Count == 0)
                            {
                                <img src="/Images/120/90/images/no-image.jpg"  alt="@item.Title"
                             title="@item.Title" />
                            }
                            else
                            {
                                <img src="/Images/120/90/classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid"  alt="@item.Title"
                             title="@item.Title"/>
                            }
                        
                            <span class="paid-customer">&nbsp;</span>
                            </div>
                    </td>
                    <td>
                        <h5>@item.Title</h5>
                        <p>
                            @if (item.Description.Length > 200)
                            {<text>@Html.Raw(@item.Description.Substring(0, 200) + "...")
                                </text>
                            }
                            else
                            {
                                <text>
                                @Html.Raw(item.Description)
                                </text>
                            }</p>
                    </td>
                    <td width="15%">
                       @if (item.Price != 0)
                    {<p class="price">
                         @SeService.GetCurrentCode(item.Id) @item.Price</p>}
                                                 <span style="display: block;margin-bottom: 6px;"><i class="icon-comment"></i>comment(@item.ClassifiedComments.Count())</span>
                                                 <b class="clear"></b>
                        <a class="btn" href="@Url.Action("Details", "ClassifiedAds", new { id = item.Id, seName = SeService.GetSeName(item.Title) })">
                            Read More »</a>
                    </td>
                </tr>
            }
            @foreach (var item in Model.Where(x => x.IsEnhanced == false))
            {
                <tr>
                    <td class="table-img">
                        <div class="thumbnail">
                            @if (item.ClassifiedPicture.Count == 0)
                            {
                                <img src="/Images/120/90/images/no-image.jpg" alt="@item.Title"
                             title="@item.Title" />
                            }
                            else
                            {
                                <img src="/Images/120/90//classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid"  alt="@item.Title"
                             title="@item.Title" />
                            }
                        </div>
                    </td>
                    <td>
                        <h5>@item.Title</h5>
                        <p>
                            @if (item.Description.Length > 200)
                            {<text>@Html.Raw(@item.Description.Substring(0, 200) + "...")
                                </text>
                            }
                            else
                            {
                                <text>
                                @Html.Raw(item.Description)
                                </text>
                            }</p>
                    </td>
                    <td width="15%">
                        @if (item.Price != 0)
                    {<p class="price">
                         @SeService.GetCurrentCode(item.Id) @item.Price</p>}
                                                 <span style="display: block;margin-bottom: 6px;"><i class="icon-comment"></i>comment(@item.ClassifiedComments.Count())</span>
                                                 <b class="clear"></b>
                        <a class="btn" href="@Url.Action("Details", "ClassifiedAds", new { id = item.Id, seName = SeService.GetSeName(item.Title) })">
                            Read More »</a>
                    </td>
                </tr>
            }
        </table>
        <div class="clear">
        </div>
        @if (Model.TotalItemCount > 0)
        {
            <div class="pagingContainer noprint">
                @Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)
            </div>
        }
    </div>
</div>
